package gui;

import java.util.List;

import javax.swing.JLabel;
import javax.swing.JComboBox;

import server.ejb.beans.Bahn;

public class MaskLandebahn extends Masks {
	private static final long serialVersionUID = 1L;
	
	private JLabel lblNewLabel;
	private JComboBox<Integer> cbxLandebahn;
	
	private List<Bahn> bahnListe;
	/**
	 * Create the panel.
	 */
	public MaskLandebahn() 
	{
		super();
		
		lblNewLabel = new JLabel("Landebahn:");
		lblNewLabel.setBounds(37, 17, 75, 14);
		add(lblNewLabel);
		
		cbxLandebahn = new JComboBox<Integer>();
		cbxLandebahn.setBounds(122, 14, 250, 20);
		add(cbxLandebahn);
	}
	@Override
	public boolean checkInhalt() {
		if (cbxLandebahn.getSelectedIndex() == -1){
			return false;
		}
		return true;
	}
	
	public void setLandebahnListe(List<Bahn> bahnListe){
		this.bahnListe = bahnListe;
		cbxLandebahn.removeAllItems();
		for(Bahn b: bahnListe){
			if (b.isFrei() == true){
				cbxLandebahn.addItem(b.getBahnId());
			}
		}
	}
	
	public Bahn getSelectedLandebahn()
	{
		return bahnListe.get((int) cbxLandebahn.getSelectedItem());
	}
}
